from selenium import webdriver
from selenium.webdriver.common.by import By


class BasePage(object):

    def __init__(self,driver):
        self.driver = driver

    def get_elem(self,*loc):
        return self.driver.find_element(*loc)

    def send_msg(self,text,*loc):
        self.get_elem(*loc).send_keys(text)

    def click_btn(self,*loc):
        self.get_elem(*loc).click()

    def get_title(self):
        return self.driver.title


class BaiduPage(BasePage):

    def __init__(self,driver):
        BasePage.__init__(self,driver)
        self.driver.get('http://www.baidu.com')

    def test_search(self):
        input = (By.ID,'kw')
        self.send_msg('selenium',*input)
        btn = (By.ID,'su')
        self.click_btn(*btn)


if __name__ == '__main__':
    driver = webdriver.Chrome()
    driver.maximize_window()
    BaiduPage = BaiduPage(driver)
    BaiduPage.test_search()